﻿#region Namespace References

using System;
using DynConDevCorp.OpenArch.SmartData.Interfaces.EventArgClasses;

#endregion

namespace DynConDevCorp.OpenArch.SmartData.Interfaces.EventArgClasses
{
    /// <summary>
    /// Argument class passed with ValueChanged event.
    /// </summary>
    public class FieldDisplayValueChangedEventArgs : EffectEventArgs
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="DisplayValueChangedEventArgs"/> class.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="oldDisplayValue">The old display value.</param>
        /// <param name="newDisplayValue">The new display value.</param>
        public FieldDisplayValueChangedEventArgs(ISmartEntity sender, string fieldName, string oldDisplayValue,
                                                 string newDisplayValue)
            : base(EffectCauses.FieldDisplayValueChanged, sender)
        {
            Sender = sender;
            FieldName = fieldName;
            OldDisplayValue = oldDisplayValue;
            NewDisplayValue = newDisplayValue;
        }

        #endregion

        #region Public Static Methods

        /// <summary>
        /// Makes the field args.
        /// </summary>
        /// <param name="originator">The originator.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="original">The original.</param>
        /// <returns></returns>
        public static FieldDisplayValueChangedEventArgs MakeFieldArgs(ISmartEntity originator, string fieldName,
                                                                      DisplayValueChangedEventArgs original)
        {
            return new FieldDisplayValueChangedEventArgs(originator, fieldName, original.OldDisplayValue,
                                                         original.NewDisplayValue);
        }

        #endregion

        #region Public Instance Properties

        /// <summary>
        /// Gets or sets the name of the field.
        /// </summary>
        /// <value>The name of the field.</value>
        public string FieldName { get; private set; }

        /// <summary>
        /// Gets or sets the new display value.
        /// </summary>
        /// <value>The new display value.</value>
        public string NewDisplayValue { get; private set; }

        /// <summary>
        /// Gets or sets the old display value.
        /// </summary>
        /// <value>The old display value.</value>
        public string OldDisplayValue { get; private set; }

        /// <summary>
        /// Gets or sets the sender.
        /// </summary>
        /// <value>The sender.</value>
        public ISmartEntity Sender { get; private set; }

        #endregion
    }
}